
/**		
 * 
 *	uk.co.lmfm.guppy.view.components.alert.AlertView
 *	
 *	@version 1.00 | Feb 2, 2010
 *	@author Justin Windle
 *  
 **/
 
package uk.co.lmfm.guppy.view.components.alert 
{
	import uk.co.lmfm.guppy.model.vo.AlertVO;
	import uk.co.lmfm.guppy.view.components.core.AbstractView;
	import uk.co.lmfm.guppy.view.components.core.IViewComponent;
	import uk.co.lmfm.guppy.view.components.events.PopUpViewEvent;

	/**
	 * AlertView
	 */
	public class AlertView extends AbstractView implements IViewComponent 
	{
		//	----------------------------------------------------------------
		//	PRIVATE MEMBERS
		//	----------------------------------------------------------------

		private var _popup : AlertPopup;

		//	----------------------------------------------------------------
		//	CONSTRUCTOR
		//	----------------------------------------------------------------

		public function AlertView()
		{
			super();
		}

		//	----------------------------------------------------------------
		//	PUBLIC METHODS
		//	----------------------------------------------------------------

		public function showAlert(alert : AlertVO) : void
		{
			if(_popup)
			{
				_popup.removeEventListener(PopUpViewEvent.CONFIRM, onConfirm);
				removeChild(_popup);
				_popup = null;
			}
			
			_popup = new AlertPopup(alert);
			_popup.addEventListener(PopUpViewEvent.CONFIRM, onConfirm);
			addChild(_popup);
			_popup.show();
			
			show();
		}

		private function onConfirm(event : PopUpViewEvent) : void
		{
			// TODO callback
			hide();
		}
	}
}
